#include "gfxDamageTextFX.h"
#include <QDebug>

GFXDamageTextFX::GFXDamageTextFX(qint32 amount, ClientEntity *entity, QGraphicsItem *parent)
   : GFXItem(entity, parent)
{
   mStartLoc = entity->target->pos.toPointF();
   mColor = entity->base.color;
   mAmount = amount;
}

GFXDamageTextFX::~GFXDamageTextFX()
{
}

QRectF GFXDamageTextFX::boundingRect() const
{
   qreal penWidth = 1;
   return QRectF(-10 - penWidth / 2, -10 - penWidth / 2, 20 + penWidth, 20 + penWidth);
}


void GFXDamageTextFX::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
{
   painter->setPen(mColor);
   painter->drawText(0,0, QString::number(mAmount));
}


void GFXDamageTextFX::tick()
{
   mTicksAlive++;
   if (mTicksAlive > 30)
      mActive = false;
   if (mTicksAlive == 1)
      setPos(mStartLoc);
   moveBy(0.0, -0.5);
}
